from django.contrib import admin

from .models import Author, Category, Product, Comment


# Register your models here.
@admin.register(Author)
class AuthorAdmin(admin.ModelAdmin):
    list_display = ('UID', 'name')
    list_display_links = ('UID',)
    list_per_page = 15
    search_fields = ('UID',)


@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
    list_display = ('category_name',)

@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
    def _show_author_list(self, obj):
        return [a.name for a in obj.author_list.all()]

    list_display = ('title', 'BVID', '_show_author_list', 'category', 'play_cnt_list', 'like_cnt_list', 'coin_cnt_list')
    ordering = ('play_cnt_list', 'like_cnt_list', 'coin_cnt_list')
    list_display_links = ('title', 'BVID')
    search_fields = ('title', 'BVID')
    list_per_page = 15

@admin.register(Comment)
class CommentAdmin(admin.ModelAdmin):
    list_display = ('BVID', 'video_url_list', 'text_list')
